/**
 * Created by DukeCrushIt on 2015/7/31.
 */
class Pet {
    //data from server
    public album:boolean=false;
    public autoHairCd:number=0;//相册
    public autoHairPer:number=2;
    public buyTime:number = 0;
    public creatTime:number=0;
    public clickHairCd:number=0;
    public clickTimes:number=0;
    public clickHairCdTime:number=0;
    public clickHairPer:number = 0;
    public dateCd:number=0;
    public dateCdTime:number;
    public decay:number=0;//衰减值
    public decayInterval:number=0;//衰减间隔
    public  figureId:number=0;
    public fondleMaxMood:number=0;//抚摸增加的心情值上限
    public  fondleMood:number=0;//抚摸增加的心情值
    public  grade:number=0;//等级
    public  hair:number=0;//升级需要消耗的毛
    public lastAutoTime:number;
    public lastGleanTime:number;
    public lastSyncClickTime;
    public  lastModifyTime:number=0;
    public  maxDateTimes:number=0;
    public  maxMood:number=0;
    public  mood:number=0;
    public  name:string="";
    public  petId:number=0;
    public  rear:boolean=false;//是否是做饲养状态
    public sex:number=0;
    public sexOrientation:number=0;
    public type:number=0;
    public userId:number=0;
    public updateTime:number;
    public inDate:boolean=false;
    public gradeHair:number;
    public dateTimes:number=0;
    public dateSlogan:string;
    public depth:number = 0;

    //next
    public nextAutoHairPer:number = 0;
    public nextClickHairPer:number = 0;
    public userFigureurl:string = "";
    public userName:string = "";
    public usedAutoHairPer:number = 0;
    public constructor(data:any){
        if( data != null && data != undefined)
            this.initFromData(data);
    }
    public initFromData(data:any){
        this.album = data.album ;
        this.autoHairCd = data.autoHairCd ;
        this.autoHairPer = data.autoHairPer ;
        this.clickHairCd = data.autoHairCd ;
        this.clickTimes = data.clickTimes ;
        this.dateCd = data.dateCd ;
        this.decay = data.decay ;//衰减值
        this.decayInterval = data.decayInterval ;//衰减间隔
        this.figureId = data.figureId ;
        this.fondleMaxMood = data.fondleMaxMood ;//抚摸增加的心情值上限
        this.fondleMood = data.fondleMood ;//抚摸增加的心情值
        this.grade = data.grade ;//等级
        this.hair = data.hair ;//累积的毛
        this.lastModifyTime = data.lastModifyTime ;
        this.maxDateTimes = data.maxDateTimes ;
        this.maxMood = data.maxMood ;
        this.mood = data.mood ;
        this.name = data.name;
        this.petId = data.petId ;
        this.rear = data.rear;//是否是做饲养状态
        this.sex = data.sex;
        this.sexOrientation = data.sexOrientation;
        this.type = data.type;
        this.userId = data.userId;
        this.clickHairPer = data.clickHairPer;
        this.buyTime = data.buyTime;
        this.creatTime = data.creatTime;
        this.dateCdTime = data.dateCdTime;
        this.lastAutoTime = data.lastAutoTime;
        this.lastGleanTime = data.lastGleanTime;
        this.lastSyncClickTime = data.lastSyncClickTime;
        this.updateTime = data.updateTime;
        this.clickHairCdTime = data.clickHairCdTime;
        this.inDate = data.inDate;
        this.gradeHair = data.gradeHair;
        //this.autoHairs = data.autoHairs;
        this.dateTimes = data.dateTimes;
        this.dateSlogan = data.dateSlogan;
        this.nextAutoHairPer = data.nextAutoHairPer;
        this.nextClickHairPer = data.nextClickHairPer;
        this.userFigureurl = data.userFigureurl;
        this.userName = data.userName;
        this.lastAutoTime = data.lastAutoTime;
        this.usedAutoHairPer = data.usedAutoHairPer;
    }

    public getHair():number{
        return Math.round(this.autoHairPer*this.usedAutoHairPer/100);//Math.round(this.autoHairPer*(1+BuffMgr.getInstance().getHairAddByPetId(this.petId)/100));
    }
}